package com.lzt.yijian.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lzt.yijian.R;
import com.lzt.yijian.bean.Subjects;

import java.util.List;

public class MovieAdapter extends RecyclerView.Adapter<MovieAdapter.MovieViewHolder> {

    private final Context mContext;
    private final List<Subjects> mData;

    public MovieAdapter(Context context, List<Subjects> data) {
        mContext = context;
        mData = data;
    }

    @NonNull
    @Override
    public MovieViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_movie, parent, false);
        MovieViewHolder viewHolder = new MovieViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull MovieViewHolder holder, int position) {
        Subjects mSubjects = mData.get(position);
        holder.mItemMovieTitle.setText(mSubjects.getTitle());
    }

    @Override
    public int getItemCount() {
        return mData.size();
    }


    class MovieViewHolder extends RecyclerView.ViewHolder {
        TextView mItemMovieTitle;

        MovieViewHolder(View view) {
            super(view);
            mItemMovieTitle = view.findViewById(R.id.item_movie_title);
        }
    }
}
